package cn.spike.rockcc.fallback;

import cn.spike.rockcc.errorenum.GlobalExceptionCode;
import cn.spike.rockcc.feign.MediaFeignClient;
import cn.spike.rockcc.result.JSONResult;
import com.sun.org.apache.bcel.internal.generic.NEW;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author:spike
 * @create:2023-03-19 15:57
 */
@Component
public class MediaFeignFallbackFactory implements FallbackFactory<MediaFeignClient> {
    @Override
    public MediaFeignClient create(Throwable throwable) {
        return new MediaFeignClient() {
            @Override
            public JSONResult getMediaByCourseId(Long id) {
                return JSONResult.error(GlobalExceptionCode.MEDIA_SERVER_EXCEPTION);
            }

            @Override
            public JSONResult getMediaById(Long id) {
                return JSONResult.error(GlobalExceptionCode.MEDIA_SERVER_EXCEPTION);
            }
        };
    }
}
